package cn.ch.train.business.controller.admin;

import cn.ch.train.common.context.LoginMemberContext;
import cn.ch.train.common.response.CommonResponse;
import cn.ch.train.common.response.PageResult;
import cn.ch.train.business.request.DailyTrainQueryParam;
import cn.ch.train.business.request.DailyTrainSaveParam;
import cn.ch.train.business.response.DailyTrainQueryResult;
import cn.ch.train.business.service.DailyTrainService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/daily-train")
public class DailyTrainAdminController {
    @Autowired
    private DailyTrainService dailyTrainService;

    @PostMapping("/save")
    public CommonResponse save(@Valid @RequestBody DailyTrainSaveParam param) {
        dailyTrainService.save(param);
        return new CommonResponse<>();
    }

    @GetMapping("/query-list")
    public CommonResponse<PageResult<DailyTrainQueryResult>> queryList(@Valid DailyTrainQueryParam param) {
        PageResult<DailyTrainQueryResult> dailyTrainList = dailyTrainService.queryList(param);
        return new CommonResponse<>(dailyTrainList);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResponse delete(@PathVariable Long id) {
        dailyTrainService.delete(id);
        return new CommonResponse<>();
    }

}
